#!/bin/bash
ROOT=$PWD
SRC=~/.gnome2/rhythmbox/plugins/RBLyrics
VERSION=`svn info $SRC | grep Revision | awk '{print $2}'`
DEST="${ROOT}/rblyrics-0.1.$VERSION"
# remove old files
if [ -x $DEST ];then
	rm -rf $DEST
fi
# make directory structure
APPDIR=$DEST/usr/lib/rhythmbox/plugins/RBLyrics
CONTROL=$DEST/DEBIAN/control
mkdir -p $APPDIR
mkdir -p `dirname $CONTROL`
# copy app files
cd $SRC
for i in `find . -name .svn -prune -o -type f -print | grep -v po$ | grep -v conf$ | grep -v doc`;
do
	cp --parents -t $APPDIR $i
done
# write control
cd $ROOT
cp control $CONTROL
SIZE=`du $APPDIR -sc | tail -n 1 | awk '{print $1}'`
perl -p -i -e "s|^Version:*$|Version:\ 0.1.$VERSION|g" $CONTROL
perl -p -i -e "s|^Installed-Size:*$|Installed-Size:\ $SIZE|g" $CONTROL
# package
dpkg -b $DEST $DEST.deb
